/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package session03;

import java.io.Console;

/**
 *
 * @author macbookpro
 */
public class ConsoleTest {

    public static void main(String[] args) {
        Console cs = System.console();

        if (cs == null) {
            System.out.println("Can't get Console");
            throw new RuntimeException("Can't run w/out a console!");
        }
        String formatString = "%1$4s %2$10s %3$10s%n";

        String name = cs.readLine("Your Name: ");
        char pass[] = cs.readPassword("Your password: ");
        cs.printf("Your password is: %s%n", String.valueOf(pass));
        cs.printf(formatString, "Idx", "A", "B");
        cs.printf(formatString, "1", "10", "100");
        cs.printf(formatString, "2", "20", "200");
        cs.printf(formatString, "3", "30", "300");
        cs.printf(formatString, "4", "40", "400");
    }
}
